<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="JS/jquery-1.11.1.min.js"></script>
    <script src="JS/echarts.min.js"></script>
  <style>
    #main{
      width: 600px;
      height: 400px;
    }
  </style>
</head>
<body>
  <h1 onclick="show()">Echart图表测试</h1>
  <div id="main"></div>
</body>
<script>
  //获取id为main
  var div=document.getElementById('main')
  var myChart = echarts.init(div);
  // 指定图表的配置项和数据
  var option = {
    title: {text: 'ECharts 入门示例'},
    tooltip: {},
    legend: {data:['销量']},
    xAxis: {data: []  },
    yAxis: {},
    series: [{
      name: '销量',
      type: 'bar',
      data: []
    }]
  };
  myChart.setOption(option);
  //通过请求  更新图标数据
  function show(){
    var url="http://localhost:8080/taobao/echart";
    $.get(url).done(function (data) {
      console.log(data);
      myChart.setOption({
        xAxis: {data: data.title},
        yAxis: {},
        series: [{
          name: '销量',
          data: data.data
        }]
      });
    });
  }
</script>
</html>